document.addEventListener('DOMContentLoaded', () => {
    const entryDiv = document.querySelector('.dictionary-entry');
    console.log("hi");
    // 从 storage 中读取保存的 LLM 回复结果
    chrome.storage.local.get(['llmResponse'], (result) => {
        if (result.llmResponse) {
            entryDiv.innerHTML = result.llmResponse;
            console.log(result.llmResponse);
        } else {
            entryDiv.innerHTML = "<p>No LLM response available.</p>";
        }
    });
});


// 监听 storage 的变化
chrome.storage.onChanged.addListener((changes, namespace) => {
    if (namespace === 'local' && changes.llmResponse) {
        const entryDiv = document.querySelector('.dictionary-entry');
        entryDiv.innerHTML = changes.llmResponse.newValue;
    }
});